// ***************************************************************************************
// Copyright (c) 2023-2025 Peng Cheng Laboratory
// Copyright (c) 2023-2025 Institute of Computing Technology, Chinese Academy of Sciences
// Copyright (c) 2023-2025 Beijing Institute of Open Source Chip
//
// iEDA is licensed under Mulan PSL v2.
// You can use this software according to the terms and conditions of the Mulan PSL v2.
// You may obtain a copy of Mulan PSL v2 at:
// http://license.coscl.org.cn/MulanPSL2
//
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
// EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
// MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
//
// See the Mulan PSL v2 for more details.
// ***************************************************************************************
#pragma once
/**
 * @File Name: contest_dm.h
 * @Brief :
 * @Author : Yell (12112088@qq.com)
 * @Version : 1.0
 * @Creat Date : 2023-09-15
 *
 */
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <map>
#include <string>
#include <vector>

#include "IdbDesign.h"
#include "IdbLayout.h"
#include "contest_db.h"
#include "contest_wrapper.h"
#include "guide_parser.h"
#include "idm.h"

namespace idb {
class IdbLayout;
class IdbDesign;
}  // namespace idb

namespace ieda_contest {
class ContestDB;
class ContestDataManager
{
 public:
  ContestDataManager(double gcell_x, double gcell_y, std::string guide_input, std::string guide_output, std::string area_constraint_input);
  ~ContestDataManager();

  bool buildData();
  bool buildData_eva();
  bool saveData();

  // getter
  std::string get_guide_input() { return _guide_input; }
  std::string get_guide_output() { return _guide_output; }
  std::string get_area_constraint_input() { return _area_constraint_input; }
  ContestDB* get_database() { return _database; }
  idb::IdbLayout* get_idb_layout() { return _idb_layout; }
  idb::IdbDesign* get_idb_design() { return _idb_design; }

  auto& get_sta_workspace() { return _sta_workspace; }
  auto& get_lib_files() { return _lib_files; }
  auto& get_sdc_file() { return _sdc_file; }

  double get_gcell_area_constraint() { return _gcell_area_constraint; }

 private:
  std::string _guide_input;
  std::string _guide_output;
  std::string _area_constraint_input;

  double _gcell_area_constraint;

  // timing io
  std::string _sta_workspace;
  std::vector<std::string> _lib_files;
  std::string _sdc_file;

  std::string _sta_output;

  ContestDB* _database = nullptr;
  idb::IdbLayout* _idb_layout = nullptr;
  idb::IdbDesign* _idb_design = nullptr;
};

}  // namespace ieda_contest